package com.ev.scm.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

import com.ev.scm.dao.LogisticsDao;
import com.ev.scm.domain.LogisticsDO;
import com.ev.scm.service.LogisticsService;
import com.ev.scm.vo.LogisticsPageParam;
import com.ev.framework.utils.R;
import com.ev.apis.model.DsResultResponse;
import com.google.common.collect.Maps;


@Service
public class LogisticsServiceImpl implements LogisticsService {
    @Autowired
    private LogisticsDao logisticsDao;

    @Override
    public LogisticsDO get(Long id) {
        return logisticsDao.get(id);
    }

    @Override
    public Map<String, Object> getByOutId(Long outId) {
        return logisticsDao.getByOutId(outId);
    }

    @Override
    public List<Map<String, Object>> listByOutIds(Long[] outIds) {
        return logisticsDao.listByOutIds(outIds);
    }

    @Override
    public int batchRemoveByOutIds(Long[] outIds) {
        return logisticsDao.batchRemoveByOutIds(outIds);
    }

    @Override
    public int updateByOutId(LogisticsDO logistics) {
        return logisticsDao.updateByOutId(logistics);
    }

    @Override
    public List<LogisticsDO> list(Map<String, Object> map) {
        return logisticsDao.list(map);
    }

    @Override
    public int count(Map<String, Object> map) {
        return logisticsDao.count(map);
    }

    @Override
    public int save(LogisticsDO logistics) {
        return logisticsDao.save(logistics);
    }

    @Override
    public int remove(Long id) {
        return logisticsDao.remove(id);
    }

    @Override
    public int batchRemove(Long[] ids) {
        return logisticsDao.batchRemove(ids);
    }

    @Override
    public R saveAndVerify(LogisticsDO saveParam) {
        return logisticsDao.save(saveParam) > 0 ? R.ok() : R.error();
    }

    @Override
    public Map<String, Object> getById(Long id) {
        LogisticsDO logistics = logisticsDao.get(id);
        Map<String, Object> result = Maps.newHashMap();
        if (logistics !=null){
            result.put("data",logistics);
            return result;
        }
        return result;
    }

    @Override
    public Map<String, Object> pageList(LogisticsPageParam pageParam) {
        Map<String, Object> result = Maps.newHashMap();
        List<Map<String, Object>> data = logisticsDao.pageList(pageParam);
        if (data.size() > 0) {
            int total = logisticsDao.pageCount(pageParam);
            result.put("data", new DsResultResponse(pageParam.getPageno(), pageParam.getPagesize(), total, data));
        }
        return result;
    }

}
